package com.generator.marketManage.customerManage.controller;


import com.generator.marketManage.customerManage.pojo.MarketCustomManage;
import com.generator.marketManage.customerManage.pojo.Users;
import com.generator.marketManage.customerManage.service.MarketCustomManageService;
import com.generator.util.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 88168
 * @since 2022-10-04
 */
@Controller
@RequestMapping("market/customer")
public class MarketCustomController {
    @Autowired
    private MarketCustomManageService service;

    /**
     *
     * @param customManage
     * @param pageModel
     * @return //用户列表（分页）
     */

    @ResponseBody
    @RequestMapping("/customList")
    public PageModel<MarketCustomManage> customList( MarketCustomManage customManage, PageModel<MarketCustomManage> pageModel){

        System.out.println(pageModel);
        PageModel<MarketCustomManage> customerList = service.getMarketCustom(customManage,pageModel);
        return customerList;
    }
    @ResponseBody
    @RequestMapping("/getMoreCondition")
    public PageModel<MarketCustomManage> getMoreCondition( MarketCustomManage customManage, PageModel<MarketCustomManage> pageModel){
        PageModel<MarketCustomManage> customerList = service.getMoreCondition(customManage,pageModel);
        return customerList;
    }

    /**
     *
     * @param customName
     * @return 获取一个用户信息
     */

    @GetMapping("/customOne/{customName}")
   @ResponseBody
    public MarketCustomManage customOne(@PathVariable String customName){
        MarketCustomManage customer = service.getcustomOne(customName);
        System.out.println("_______________________________");
        System.out.println(customer);
        return customer;
    }

    /**
     *
     * @param custName
     * @return注销
     */
    @GetMapping("/logout/{custName}")
   @ResponseBody
    public String Marketlogout(@PathVariable String custName){
        String update = service.logout(custName);

        return update;
    }

    /**
     *
     * @param custName
     * @return  恢复
     *
     */
    @GetMapping("/refresh/{custName}")
   @ResponseBody
    public String refresh(@PathVariable String custName){
        String update = service.refresh(custName);
        return update;
    }
    /**
     *
     * @param marketCustomManage
     * @return
     */
    @GetMapping("/update")
    @ResponseBody
    public String updateCustom(MarketCustomManage marketCustomManage) {
        String s = service.updateCustom(marketCustomManage);

       return s;
    }

    /**
     * 添加
     * @param marketCustomManage
     * @return
     */
    @GetMapping("/add")
    @ResponseBody
    public String addCustom(MarketCustomManage marketCustomManage) {
        String s = service.addCustom(marketCustomManage);

       return s;
    }

    /**
     * 分配
     * @return
     */
    @GetMapping("/distribute")
    @ResponseBody
    public  List<Users> distrubute() {
        List<Users> users = service.selectMarketMembers(null);
       return users;
    }

    /**
     * 更新
     * @param marketCustomManage
     * @return
     */
    @GetMapping("/updateDistribute")
    @ResponseBody
    public  String adddistrubute( MarketCustomManage marketCustomManage) {
        String s = service.updateDistribute(marketCustomManage);
        return s;
    }
}

